package com.gxa.dao.impl;

import com.gxa.common.Constants;
import com.gxa.dao.HouseDao;
import com.gxa.dbutils.JdbcBuild;
import com.gxa.pojo.House;

import java.sql.SQLException;
import java.util.List;

public class HouseDaoImpl extends JdbcBuild implements HouseDao {
    /**
     * 与数据库交互：分页查询房产信息
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Override
    public List queryHouseList(Integer currentPage, Integer pageSize) throws SQLException {
        String sql = "select * from house where status = ? limit ?,?";
        Object[] params = {Constants.STATUS_OK,currentPage,pageSize};
        List<House> houses = super.queryListEntity(House.class, sql, params);
        return houses;
    }

    @Override
    public Integer countHouse() throws SQLException {
        String sql = "select count(*) from house where status = ?";
        Object[] params = {Constants.STATUS_OK};
        int totalPage = super.findAllForInt(sql, params);
        return totalPage;
    }
}
